/**
 * Copyright(c) 2014 Xunton Solutions
 *
 * History:
 *   15-4-15 下午5:07 Created by dwzhang
 */
package com.jade.framework.base.util;

/**
 * UserAgent的工具类。
 *
 * @author <a href="mailto:dwzhang@xunton.com">dwzhang</a> 
 * @version 1.0 15-4-15 下午5:07
 */
public class UserAgentUtils
{
    protected static final String ANDROID = "android";
    protected static final String IPHONE = "iphone";
    protected static final String IPAD = "ipad";
    protected static final String WINPHONE = "winphone";
    protected static final String UNKOWN = "unknown";

    public static String getMobileType(String ua)
    {
        if (StringUtilsEx.isBlank(ua)) {
            return UNKOWN;
        }

        if (StringUtilsEx.indexOfIgnoreCase(ua, ANDROID) > 0) {
            return ANDROID;
        }
        else if (StringUtilsEx.indexOfIgnoreCase(ua, IPHONE) > 0) {
            return IPHONE;
        }
        else if (StringUtilsEx.indexOfIgnoreCase(ua, IPAD) > 0) {
            return IPAD;
        }
        else if (StringUtilsEx.indexOfIgnoreCase(ua, "windows phone") > 0) {
            return WINPHONE;
        }
        else {
            return UNKOWN;
        }
    }
}
